import axios from "../index"
import type { CouponApi,CouponPageVO ,ApiResponse} from "@/common/type"


export default {
    //分页获取优惠卷
    async page(page,pageSize) {
        return (await axios.get(`/admin/coupon/${page}?pageSize=${pageSize}`)).data as ApiResponse<CouponPageVO>
    },
    // 新增优惠卷
    async add(form) {
        return (await axios.post("/admin/coupon", form)).data as ApiResponse<null>
    },
    // 删除优惠卷
    async delete(ids) {
        const queryString = ids.map(id => `ids=${id}`).join('&');  
        return (await axios.delete(`/admin/coupon?${queryString}`)).data as ApiResponse<null>
    },
    // 编辑优惠卷
    async update(form) {
        return (await axios.put("/admin/coupon", form)).data as ApiResponse<null>
    }
} as CouponApi